From 42fa1ebe7d37ba0577f1cfcf5d2449e87187ff62 Mon Sep 17 00:00:00 2001 From: robertl Date: Sun, 6 Apr 2008 04:36:38 +0000 Subject: [PATCH] CSV: if date is before 1/1/1970, don't crash on Windows. git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@3171 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/csv_util.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gpsbabel/csv_util.c b/gpsbabel/csv_util.c index 14c1e5040..5b662743d 100644 --- a/gpsbabel/csv_util.c +++ b/gpsbabel/csv_util.c @@ -848,13 +848,16 @@ static int writehms(char * buff, size_t bufsize, const char * format, time_t t, int gmt ) { - static struct tm * stmp; + static struct tm no_time = {0}; + static struct tm * stmp = &no_time; if (gmt) stmp = gmtime(&t); else stmp = localtime(&t); + if (stmp == NULL) stmp = &no_time; + return snprintf(buff, bufsize, format, stmp->tm_hour, stmp->tm_min, stmp->tm_sec, (stmp->tm_hour>=12?"PM":"AM") ); -- 2.30.2